Next Previous Table of Contents

Overview of the Classes in the LInteger Library

The LInteger library consists of five classes: LMisc, BMath, LInteger, LMath, and Monty. Here is a brief overview of each class:

LMisc

This class provides two basic methods: MemZero, and MemCopy used throughout the library.

Note: Included in lmisc.hxx is a templated function called LSwap. For some reason, g++ will not allow this to be a method for the LMisc class. If you get a name space collision look here! :)

BMath

This class provides methods to the perform multiprecision arithmetic on unsigned magnitudes.

The methods in this class are made public so that programmers may use them to implement algorithms which have been designed to run most effeciently on the direct binary representations of multiprecision integers.

LInteger

This class allows the instantiation of objects representing signed multiprecision integers. Basic object manipulation, such as copying and creation is easy with this class, and every C++ arithmetic operation is overloaded to allow for easy substituion in code already using ints. Constructors are included to create LIntegers out of ints or unsigned ints. The int() conversion operator is overloaded to allow the use of LIntegers in place of ints when precision can be sacrificed.

LMath

This class provides methods to perform more complex arthimetic on LIntegers than can be acheived through the overloaded operators. This class is a friend of the LInteger class. It, thus, has direct access to the binary representations of the LIntegers and can use this privelege, along with calls to BMath's methods to implement algorithms optimized for binary representations. On the other hand, methods in this class, can, of course, choose to treat the LIntegers as blackboxes.

Methods which treat their LInteger arguments as blackboxes will be safer since they are not making dangerous BMath calls. They will also be easier to code and more readable. On the other hand, methods which take advantage of their friend status to do directly binary calculations may be faster. A useful strategy for people seeking to extend the, currently meager, LMath class may be to, first, implement a version of the algorithm treating the LIntegers as blackboxes, and, then, implement another to take advantage of the friend status. Agreement between the two algorithms would, then, provide some assurance that the two algorithms were properly implemented.

Monty

This class saves information for the conversion of magnitudes to and from Montgomery representations in certain residue classes, and provides methods to perform arithmetic on these representations.


Next Previous Table of Contents